#include<bits/stdc++.h>
using namespace std;
int n,t,a[100500],flag,cnt,maxn;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++)cin>>a[i];
        maxn=0;
        for(flag=0;flag<pow(2,n);flag++){
            cnt=0;
            for(int i=1;i<n;i++){
                for(int j=i-1;j>=0;j--){
                    //cout<< (flag>>i)%2 <<" "<< (flag>>j)%2 <<endl;
                    if((flag>>i)%2==(flag>>j)%2){
                        if(a[i]==a[j])cnt+=a[i];
                        break;
                    }
                }
            }
            maxn=max(maxn,cnt);
        }
        cout<<maxn<<endl;
    }
    return 0;
}
